import sys
from Tkinter import *
import os

def clrDir():
    cwd.set('')


if __name__ == '__main__':
    root = Tk()  
    root.title('My directory Lister v1.1')
    #label = Label(root, text = 'My directory Lister v1.1')
    cwd = StringVar(root)
    dir1 = Label(root, fg='blue', font=('Helvetica', 22, 'bold'))
    dir1.pack()
    
    dirfm = Frame(root)
    dirsb = Scrollbar(dirfm)
    dirsb.pack(side=RIGHT, fill=Y)
    
    dirs = Listbox(dirfm, height=15,
      width=50, yscrollcommand=dirsb.set) 
    #dirs.bind('<Double-1>', setDirAndGo)
    dirs.pack(side=LEFT, fill=BOTH)
    
    dirsb.config(command=dirs.yview)
    dirfm.pack()
    
    dirn = Entry(root, width=50,textvariable=cwd)
    #dirn.bind('<Return>', doLS)
    dirn.pack()
    
    bfm = Frame(root)
    clr = Button(bfm, text='Clear',
      command = clrDir,
      activeforeground = 'white',                                               
      activebackground = 'blue')
    ls = Button(bfm, 
      text = 'List Directory',
      activeforeground = 'white',
      activebackground = 'green')
    quit = Button(bfm, text='Quit',
      activeforeground='white',
      activebackground='red')
    clr.pack(side=LEFT)
    ls.pack(side=LEFT)
    quit.pack(side=LEFT)
    bfm.pack()
    
    cwd.set(os.curdir)
    for i in os.listdir('./'):
        dirs.insert(END, i)
    root.mainloop()
    